
<div class="jobGroups form">
  
<?php echo $this->Form->create('JobGroup');?>
  
  <div id="accordianWrapper">
  
    <!-- header for an accordian tab -->
    <h3 class="accordianLegend">
      <a href="#"><?php echo $addNewGroup ? 'Add Job Group' : 'Edit Job Group'; ?></a>
    </h3>
    
    <!-- content of an accordian panel -->
    <div class="accordionPanel"> 
    <?php
      //------------- Id's
      if($editGroup) {
        echo $this->Form->input('JobGroup.id');
        if(isset($this->data['JobGroupAltName']['id'])) {
          echo $this->Form->input('JobGroupAltName.id');
        }
      }
    
      //------------ Regular inputs
      echo $this->Form->input('JobGroup.id');
      ?>
      
      <div id="jobGroupRadioWrapper" class="required">
      <label for="jobGroupNameRadioGroup" >Group Directory</label>
        <div id="jobGroupNameRadioGroup" class="override_required">
        <?php
        // Job Group Name radios
        foreach($newGroupDirsAndFullPath as $dir => $abs_path) {
          // I'm including some custom html attributes for each radio 
          // to hold data about each job group (I'm using jQuery to extract those vals)
          $radioGroupAttributes = array('legend' => false,
                                        'hiddenField'=>false,
                                        'class'=>'jobGroupRadios',
                                        // custom attributes:
                                        'data-jobGroupFullPath'=>$abs_path 
                                       );
          // Get a Group Name array formatted for a radio group (get the radios to include the name in their 'val')
          $newGroupDirsKeyAndVal = array();
          $newGroupDirsKeyAndVal[$dir] = $dir;
          echo "<div class='singleRadioWrapper'>";
          echo $this->Form->radio('JobGroup.name', $newGroupDirsKeyAndVal, $radioGroupAttributes);
          echo "</div>";
        }
        ?>
        </div>  
      </div> 
      <?php
      // Job Group Abs Path
      $guidance = "<p class='guidance'>You must select group name above to populate this field.</p>";
      $options = array('label'=>'Absolute Path of Group Directory', 'after'=>$guidance);
      echo $this->MyForm->dynamicInputsDisabledAndHidden('JobGroup.dir_abs_path', 'JobGroupDirAbsPathDiv',
                                                         'text',$options);
      
      //$tooltipBody = "To populate the Absolute Path, you must select the Group Directory above.";
      //$absPathInputs = $this->MyForm->dynamicInputsDisabledAndHidden('JobGroup.dir_abs_path', 'JobGroupDirAbsPathDiv',
      //                                                   'text',$options);
      //echo $this->Tooltip->warning($absPathInputs, $tooltipBody);
      
      
      // Job Group Alt Name
      echo $this->Form->input('JobGroupAltName.name', array('label'=>'Alternate Job Group Name',
                                                       'div' => 'override_required'));
    ?>
    </div> <!-- end .accordionPanel -->
  </div> <!-- end #accordianWrapper -->
  
  <!-- handling the entire SUBMIT BUTTON manually for finer control -->
  <div class="submit">
  <?php 
    //////////////////////////////////////////
    // Configure SUBMIT BUTTON and its tooltip
    $disabledStr = '';
    if($addNewGroup && $validated) $disabledStr = 'disabled="disabled"';
    $classStr = '';
    if($addNewGroup && $validated) $classStr = 'class="disabledSubmit"';

    $submitButtonStr = "<input $disabledStr $classStr type='submit' value='Submit' />";
    $tooltipBody = "Select Group Directory first.";

    if($addNewGroup && $validated) {
        // output the submit btn and all needed stuff for the tooltip
        echo $this->Tooltip->warning($submitButtonStr, $tooltipBody);
    }
    // If the group did not validate, the group will already be selected in the returned
    // form, so we don't need to tell the user that those must be selected, so no tooltip.
    else {
      echo $this->Form->end('Submit'); 
    }
  ?>
  </div> <!-- end .submit div -->
</div>





<!--<div class="actions">
	<h3><?php __('Actions'); ?></h3>
	<ul>

		<li><?php echo $this->Html->link(__('Delete', true), array('action' => 'delete', $this->Form->value('JobGroup.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $this->Form->value('JobGroup.id'))); ?></li>
		<li><?php echo $this->Html->link(__('List Job Groups', true), array('action' => 'index'));?></li>
		<li><?php echo $this->Html->link(__('List Job Group Alt Names', true), array('controller' => 'job_group_alt_names', 'action' => 'index')); ?> </li>
		<li><?php echo $this->Html->link(__('New Job Group Alt Name', true), array('controller' => 'job_group_alt_names', 'action' => 'add')); ?> </li>
		<li><?php echo $this->Html->link(__('List Jobs', true), array('controller' => 'jobs', 'action' => 'index')); ?> </li>
		<li><?php echo $this->Html->link(__('New Job', true), array('controller' => 'jobs', 'action' => 'add')); ?> </li>
	</ul>
</div>-->